{% extends "base.html" %}

{% block content %}
<div class="admin-dashboard container">
    <div class="admin-header">
        <h1>名言管理</h1>
        <a href="{{ url_for('admin.index') }}" class="btn">返回首页</a>
    </div>

    <div class="admin-form card">
        <h2>添加新名言</h2>
        <form method="POST" action="{{ url_for('admin.manage_quotes') }}">
            {{ form.hidden_tag() }}
            <div class="form-group">
                {{ form.content.label }}
                {{ form.content(class="form-control", rows=3) }}
                {% for error in form.content.errors %}
                <span class="error">{{ error }}</span>
                {% endfor %}
            </div>
            <div class="form-group">
                {{ form.author.label }}
                {{ form.author(class="form-control") }}
                {% for error in form.author.errors %}
                <span class="error">{{ error }}</span>
                {% endfor %}
            </div>
            <div class="form-group checkbox">
                {{ form.is_active() }} {{ form.is_active.label }}
            </div>
            <div class="form-actions">
                <button type="submit" class="btn">添加名言</button>
            </div>
        </form>
    </div>

    <div class="table-container card">
        <h2>现有名言</h2>
        <table class="admin-table">
            <thead>
                <tr>
                    <th>内容</th>
                    <th>作者</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {% for quote in quotes %}
                <tr>
                    <td>{{ quote.content }}</td>
                    <td>{{ quote.author }}</td>
                    <td>
                        <span class="status-badge {% if quote.is_active %}active{% endif %}">
                            {{ '启用' if quote.is_active else '禁用' }}
                        </span>
                    </td>
                    <td class="action-buttons">
                        <a href="{{ url_for('admin.edit_quote', id=quote.id) }}" class="btn btn-sm">编辑</a>
                        <button class="btn btn-sm btn-danger delete-btn" data-id="{{ quote.id }}" data-type="quotes">删除</button>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}

{% block scripts %}
<script src="{{ url_for('static', filename='js/admin.js') }}"></script>
{% endblock %} 